<template>
	<view class="invite">
		<z-paging ref="paging" v-model="list" @query="queryList" :default-page-size="20">
			<view slot="top">
				<navBar title="最近联系人" bg="transparent"></navBar>
				<view class="left_pof"></view>
				<view class="right_pof"></view>
			</view>
			<view class="container">
				<view class="loading" v-if="!list.length && total == 1">
					<HevuLoading type="loading4" :opacity="0" loadingText="加载中..." text-color="#FD2A53"
						loadingIconColor="#FD2A53" />
				</view>
				<view class="list flex_r_between" v-for="(item,index) in list" :key="index">
					<view class="left flex_center">
						<view class="avatar">
							<image :src="item.avatar" mode="aspectFill"></image>
							<view class="online" v-if="item.online == 0"></view>
						</view>
						<view class="name">
							<view class="hidden">{{ item.nickname || '' }}</view>
							<text class="hidden_3">{{ item.sign || 'Ta什么也没有留下' }}</text>
						</view>
					</view>

					<view class="right" @click="shareJoinTeam(item)">邀请</view>
				</view>
			</view>
		</z-paging>
	</view>
</template>

<script>
	import navBar from '@/compentents/navBar/navBar.vue'
	import empty from '@/compentents/empty/empty.vue'
	import HevuLoading from '@/components/hevu-loading/hevu-loading.vue';
	export default {
		components: {
			navBar,
			empty,
			HevuLoading,
		},
		data() {
			return {
				page: 1,
				total: 1,
				list: [],

				eredar_user_id: 0,
			}
		},
		methods: {
			queryList(pageNo, pageSize) {
				// 0 在线
				this.$get('/v2.eredar/getChatList', {
					page: pageNo,
				}).then(res => {
					this.$refs.paging.complete(res.data.data);
				})
			},

			// 邀请加入团队
			shareJoinTeam(item) {
				this.$post('/v2.eredar/shareJoinTeam', {
					eredar_user_id: this.eredar_user_id,
					share_user_id: item.id
				}).then(res => {
					this.$util.msg(res.msg);
				});
			},
		},

		onLoad(option) {
			this.eredar_user_id = option.eredar_user_id || 0;
		},


	}
</script>

<style lang="less" scoped>
	page {
		background: #FFF;
	}

	.left_pof {
		width: 422rpx;
		height: calc(44px + var(--paging-head-top));
		background: #E5F7FE;
		filter: blur(23px);
		position: fixed;
		top: 0;
		left: 0;
		z-index: 80;
	}

	.right_pof {
		width: 436rpx;
		height: calc(44px + var(--paging-head-top));
		background: #F7EBFB;
		filter: blur(23px);
		position: fixed;
		top: 0;
		right: 0;
		z-index: 80;
	}

	.container {
		.list {
			padding: 22rpx 32rpx;

			.left {
				flex: 1;
				overflow: hidden;

				.avatar {
					width: 96rpx;
					height: 96rpx;
					margin-right: 24rpx;
					position: relative;

					image {
						width: 96rpx;
						height: 96rpx;
						border-radius: 48rpx;
						background: #D8D8D8;
					}

					.online {
						width: 32rpx;
						height: 32rpx;
						border-radius: 16rpx;
						background: #32E371;
						border: 2rpx solid #FFFFFF;
						position: absolute;
						right: 0;
						bottom: 0;
					}
				}

				.name {
					flex: 1;
					overflow: hidden;

					view {
						font-weight: 600;
						font-size: 32rpx;
						color: #131313;
					}

					text {
						font-size: 28rpx;
						color: #999999;
					}
				}
			}

			.right {
				margin-left: 32rpx;
				width: 144rpx;
				height: 56rpx;
				background: #FD2A53;
				border-radius: 12rpx;
				font-weight: 500;
				font-size: 28rpx;
				color: #FFFFFF;
				line-height: 56rpx;
				text-align: center;
			}
		}
	}
</style>